package Chapter06;

/**
 * 休眠当前线程
 * Created by a on 2017/6/11.
 */
public class Test129 {

    public static void main(String[] args) {

        Thread thread = new Thread(new Rabbit());
        Thread thread1 = new Thread(new WuGui());
        thread.start();
        thread1.start();


    }

}


class Rabbit implements Runnable {

    @Override
    public void run() {
        for (int i = 1; i < 11;i++){
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("兔子跑了"+i+"0米");
            if (i==9){
                System.out.println("兔子再睡觉");
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            if (i == 10){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("兔子到达终点了");
            }
        }
    }
}

class WuGui implements Runnable {

    @Override
    public void run() {
        for (int i = 1 ;i<11;i++){
            try {
                Thread.currentThread().sleep(1000);
                System.out.println("乌龟跑了"+i+"0米");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (i ==10){
                System.out.println("乌龟到达终点了");
            }

        }
    }
}